<template>
  <div class="pb-3 mb-0 small lh-sm border-bottom w-100">
    <strong
      ><a :href="url[1]">{{ orderChoose }}</a></strong
    >
    <h6 class="text-primary">评价：</h6>
    <div v-for="index in range(0, dataLength)" :key="index">
      <div class="row">
        <div class="col-lg-9">
          <label class="text-danger">{{ index + 1 }}.</label
          >{{ commentText[index] }}
        </div>
        <div class="col-lg-3">评价日期：{{ createTime[index] }}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      commentText: [],
      createTime: [],
      url: [],
      dataLength: "",
    };
  },
  props: ["orderChoose"],
  mounted() {
    this.axios
      .get(
        "http://122.51.157.58:8081/api-service/getJingDongComment?key=123456&orderChoose=" +
          this.orderChoose
      )
      .then((body) => {
        var result = body.data;
        this.dataLength = result.data.result.length;
        for (var i = 0; i < result.data.result.length; i++) {
          this.commentText.push(result.data.result[i].commentText);
          this.createTime.push(result.data.result[i].createTime);
          this.url.push(result.data.result[i].productUrl);
        }
        console.log(this.url);
      });
  },
  methods: {
    range(start, end) {
      var arr = [];
      for (var i = start; i < end; i++) {
        arr.push(i);
      }
      return arr;
    },
  },
};
</script>